﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AllRoles.aspx.cs" Inherits="Security_AllRoles" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>角色管理</title>
    <link href="../css/f_css.css" rel="stylesheet" type="text/css" />
    <link href="../css/listpage.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    #gv th
    {
        border:none;
    }
    #gv td
    {
        border-top:none;
        border-left:none;
        border-right:none;
        border-bottom:solid 1px #EEEEEE;
    }
    .roleTD{width:200px; vertical-align:top; text-align:left;}
    .moduleTD{width:200px; vertical-align:top; text-align:left;}
    .functionTD{width:auto; vertical-align:top; text-align:left;}
    </style>
    <script language="javascript" src="../js/subMsg.js" type="text/javascript"></script>
    <script language="javascript" src="../js/common.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
         function preCheckItems(gvID, confimrMsg) {
            if (0 == getCheckedItemsCount(gvID))
            {
                msgWarning('没有选择记录');
                return false;
            }
            if (confimrMsg) {
                if (!confirm(confimrMsg)) {
                    return false;
                }
            }
            return true;
         }
        function onRowStatusChanged(chk, rowIndex) {
            var tr = chk.parentNode.parentNode;
            if (chk.checked) {
                tr.style.backgroundColor = "#d6e2f6";
            }
            else {
                tr.style.backgroundColor = "";
            }
        }
    </script>
    <script language="javascript" type="text/javascript">
        function addRole() {
            var url = "Security/EditRoleDlg.aspx?op=add";
            window.parent.document.openDialog(url, "添加角色", addRoleCallback, 300, 160);
        }
        function addRoleCallback(type, key, value) {
            if (type == 1) {
                getElementAndClick("lkAddRoleSubmit");
            }
        }
        function getRoleUser() {
            var lstRole = getx("lstRole");
            if (lstRole.selectedIndex < 0) {
                msgWarning('没有选择角色');
                return;
            }
            var selected = lstRole.options[lstRole.selectedIndex];
            var url = "Security/AddUsersToRoleDlg.aspx?id=" + selected.value;
            window.parent.document.openDialog(url, "添加用户到角色", getRoleUserCallback, 600, 300);
        }
        function getRoleUserCallback(type, key, value) {
            if (type == 1) {
                var count = parseInt(value);
                if (value > 0) {
                    getElementAndClick("lkAfterAddUser");
                }
            }
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div class="titleText">
        用户管理 <span style="font-size: 12px; font-weight: normal;">(总记录
        <asp:Label runat="server" ID="lblTotal" Text="0"></asp:Label>)
        <asp:Label runat="server" ID="lblFiltered"></asp:Label>
        </span>
    </div>
    <div class="btdiv2">
            <asp:Button ID="btnRefresh" runat="server" CssClass="input00" Text="刷新" 
                onclick="btnRefresh_Click" />
            <asp:Button runat="server" ID="btnAddRole" OnClientClick="javascript:addRole();return false;" CssClass="input00"
                Text="添加角色" />
            <asp:LinkButton runat="server" ID="lkAddRoleSubmit" 
                onclick="lkAddRoleSubmit_Click"></asp:LinkButton>
            <asp:Button ID="btnSave" runat="server" CssClass="input00" Text="保存更新"
                onclick="btnSave_Click" />
    </div>
    <div class="tableContaner">
    <table style="width:99%; min-height:300px;">
        <tr>
            <td class="roleTD">
            <div>系统角色</div>
            <asp:ListBox runat="server" ID="lstRole" Width="100%" AutoPostBack="True" 
                    onselectedindexchanged="lstRole_SelectedIndexChanged" Rows="16"></asp:ListBox>
            </td>
            <td class="moduleTD">
            <div>
                <asp:DropDownList runat="server" ID="drpSystems" Width="100%">
                </asp:DropDownList>
            </div>
            <asp:TreeView runat="server" ID="tvModules" AutoGenerateDataBindings="False" 
                ImageSet="News" Width="100%" 
                    onselectednodechanged="tvModules_SelectedNodeChanged">
                <SelectedNodeStyle BackColor="#CCCCCC" />
                </asp:TreeView>
            </td>
            <td class="functionTD">
                <div>功能列表</div>
            <asp:CheckBoxList runat="server" ID="chklistFunctions"></asp:CheckBoxList>
            <br />
            <asp:Label runat="server" ID="lblNoFunctions" Text="无功能项" ForeColor="Red" Visible="false"></asp:Label>
            </td>
        </tr>
    </table>
    </div>
    <div>
    <div style="height:30px; line-height:30px;">
       <h4>相关用户</h4>
    </div>
    <div class="btdiv2">
    <asp:LinkButton runat="server" ID="lkAddUser" OnClientClick="javascript:getRoleUser();return false;">添加用户</asp:LinkButton>
    &nbsp;&nbsp;
    <asp:LinkButton runat="server" ID="lkDeleteUser" onclick="lkDeleteUser_Click"
        OnClientClick="javascript:if(!preCheckItems('gv', '确认从角色中删除选中的用户吗？')){return false;}">
        删除选中用户</asp:LinkButton>
    <asp:LinkButton runat="server" ID="lkAfterAddUser" onclick="lkAfterAddUser_Click"></asp:LinkButton>
    </div>
    <div style="width:99%;">
        <asp:GridView ID="gv" runat="server" CssClass="table2" AutoGenerateColumns="False">
            <Columns>
                <asp:TemplateField HeaderStyle-Width="20px" ItemStyle-HorizontalAlign="Center">
                    <HeaderTemplate>
                        <input type="checkbox" onclick="javascript:checkAll(this);" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox runat="server" ID="chk" onclick='<%# "javascript:onRowStatusChanged(this, " + Container.DataItemIndex + ");"%>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField HeaderText="姓名" DataField="Name" />
                <asp:BoundField HeaderText="登录名" DataField="LoginName" />
                <asp:BoundField HeaderText="工作证号" DataField="WorkNumber" />
                <asp:TemplateField HeaderText="创建日期">
                    <ItemTemplate><%# FormatDateTime(Eval("CreateDateTime"), false)%></ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <HeaderStyle CssClass="listhead" />
            <AlternatingRowStyle CssClass="alt" />
        </asp:GridView>
    </div>
    <asp:Label runat="server" ID="lblUserMsg" ForeColor="Red" Visible="false" Text="无用户"></asp:Label>
    </div>
    </form>
</body>
</html>
